# Maintainer: team/rust <alpine@ptrcnull.me>
pkgname=cargo-auditable
pkgver=0.6.4
pkgrel=0
pkgdesc="Cargo wrapper for embedding auditing data"
url="https://github.com/rust-secure-code/cargo-auditable"
arch="all"
license="MIT OR Apache-2.0"
depends="cmd:cargo"
# lld: for build order resolution during bootstrap, we only want rust-wasm
# (not rust) to depend on lld to prevent lld-llvm version mismatch issues.
case "$CARCH" in
s390x) ;; # limited by rust-wasm
*) checkdepends="lld rust-wasm" ;;
esac
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/rust-secure-code/cargo-auditable/archive/refs/tags/v$pkgver.tar.gz
	update-rust-libc.patch
	update-time-crate.patch
	"
options="net"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	msg "building cargo auditable"
	cargo build --release --frozen
	msg "rebuilding with cargo-auditable itself"
	PATH="$PATH:$PWD/target/release" \
		cargo auditable build --release --frozen
}

check() {
	# we have -Clink-args in default RUSTFLAGS
	# that are not valid for wasm32 code built in the tests
	unset RUSTFLAGS

	case "$CARCH" in
	s390x) cargo test --frozen -- --skip test_wasm ;;
	*) cargo test --frozen ;;
	esac
}

package() {
	install -Dm755 target/release/cargo-auditable -t "$pkgdir"/usr/bin/
	install -Dm644 cargo-auditable/cargo-auditable.1 -t "$pkgdir"/usr/share/man/man1/
}

sha512sums="
99828b8c2a5a3780480359e262c324625d493d101072452ce41ca950b3d883dcfd139680bdeacc16fd5c802241f52041b1047f6876587fbfda886b65781b971d  cargo-auditable-0.6.4.tar.gz
17b1efc2cc5c04e0566e82758b693a36f8a82b76eab9b44f5a8332ec63aa7470e60dcb752f5b059443d5e8541be5ee9d7fdf42b379b11c6cb7b33a946356b100  update-rust-libc.patch
1daa558d98a0c1a3a43b0f9cb54778485b9440e1199427a831a5bb7484eb41f8e0608fdc2348d0f5ea833694b6e2e545110578b93b5a7a4d84cf223b935cd5f0  update-time-crate.patch
"
